home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 1 / QRZ Ham Radio Callsign Database - December 1993.iso / ucsd / packet / tcpip / amiga / asrc29k.lha / mbuf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-08  |  1.9 KB  |  56 lines

  1. #ifndef    NULLBUF
  2.  
  3. #include <stdio.h>
  4. #include "global.h"
  5.  
  6. /* Basic message buffer structure */
  7. struct mbuf {
  8.     struct mbuf *next;    /* Links mbufs belonging to single packets */
  9.     struct mbuf *anext;    /* Links packets on queues */
  10.     int16 size;        /* Size of associated data buffer */
  11.     int refcnt;        /* Reference count */
  12.     struct mbuf *dup;    /* Pointer to duplicated mbuf */
  13.     char *data;        /* Active working pointers */
  14.     int16 cnt;
  15. };
  16. #define    NULLBUF    (struct mbuf *)0
  17. #define    NULLBUFP (struct mbuf **)0
  18.  
  19. #define    PULLCHAR(bpp)\
  20.  ((bpp) != NULL && (*bpp) != NULLBUF && (*bpp)->cnt > 1 ? \
  21.  ((*bpp)->cnt--,(unsigned char)*(*bpp)->data++) : pullchar(bpp))
  22.  
  23. /* In mbuf.c: */
  24. void enqueue __ARGS((struct mbuf **q,struct mbuf *bp));
  25. void append __ARGS((struct mbuf **bph,struct mbuf *bp));
  26. void free_q __ARGS((struct mbuf **q));
  27. void trim_mbuf __ARGS((struct mbuf **bpp,int16 length));
  28. struct mbuf *alloc_mbuf __ARGS((int16 size));
  29. struct mbuf *ambufw __ARGS((int16 size));
  30. struct mbuf *free_mbuf __ARGS((struct mbuf *bp));
  31. struct mbuf *dequeue __ARGS((struct mbuf **q));
  32. struct mbuf *copy_p __ARGS((struct mbuf *bp,int16 cnt));
  33. struct mbuf *free_p __ARGS((struct mbuf *bp));
  34. struct mbuf *qdata __ARGS((char *data,int16 cnt));
  35. struct mbuf *pushdown __ARGS((struct mbuf *bp,int16 size));
  36. int16 pullup __ARGS((struct mbuf **bph,char *buf,int16 cnt));
  37. int16 dup_p __ARGS((struct mbuf **hp,struct mbuf *bp,int16 offset,int16 cnt));
  38. int16 len_p __ARGS((struct mbuf *bp));
  39. int16 dqdata __ARGS((struct mbuf *bp,char *buf,unsigned cnt));
  40. int16 len_q __ARGS((struct mbuf *bp));
  41. int32 pull32 __ARGS((struct mbuf **bpp));
  42. int32 get32 __ARGS((char *cp));
  43. int16 pull16 __ARGS((struct mbuf **bpp));
  44. int16 get16 __ARGS((char *cp));
  45. char pullchar __ARGS((struct mbuf **bpp));
  46. char *put16 __ARGS((char *cp,int16 x));
  47. char *put32 __ARGS((char *cp,int32 x));
  48. int write_p __ARGS((FILE *fp,struct mbuf *bp));
  49.  
  50. #define    AUDIT(bp)    audit(bp,__FILE__,__LINE__)
  51.  
  52.  
  53. #endif    /* NULLBUF */
  54.  
  55.  
  56.